********************************************************************************
* Author: Patrick Sullivan
* Title	: Teaching Tax Brackets - Data Prep
* Date	: July 2025
********************************************************************************

clear all

*** Set Directories ***
global projectdir "###########" // GET INFO ON ThinkingAtMargin_RawData and insert file path here

cd "$projectdir"

*** Open File ***
use "$projectdir/ThinkingAtMargin_RawData"


********************************************************************************
********************************************************************************
******************************* BASIC SETUP ************************************
********************************************************************************
********************************************************************************

************************
***** Consent Form *****
************************
tab I0

encode I0, gen(I0_en)
tab I0_en
label list I0_en // Shows Label and Value

gen consent=.
label var consent "Consent to participate?"
replace consent=0 if I0_en==1
replace consent=1 if I0_en==2
label define consent 0 "No" 1 "Yes"
label val consent consent

drop I0_en

tab I0 consent // check // 8 screenouts

****************************
***** Drop Incompletes *****
****************************

tab completionstatus // 86 dropouts, 8 screenouts
drop if complete!=1 // 94 obs dropped

***************************
***** Generate OBS ID *****
***************************

gen id = _n // n goes from 1 to 1618
order id, first


********************
***** Duration *****
********************

gen Durationinminutes=Durationinsecond/60

sum Durationinminutes if complete==1, detail



********************************************************************************
********************************************************************************
******************************* VARIABLE CREATION ******************************
********************************************************************************
********************************************************************************

***********************
***** INTRO BLOCK *****
***********************

***** Device Type *****
tab I1

gen device=.
label var device "Device Type"
replace device=1 if I1=="Computer/Laptop"
replace device=2 if I1=="Tablet/Smartphone"
replace device=3 if I1=="Other"
label define device 1 "Computer/Laptop" 2 "Tablet/Smartphone" 3 "Other"
label val device device
tab I1 consent // check //


***** Self-Described Econ Knowledge *****
tab I2

encode I2, gen(I2_en)
label list I2_en // Shows Label and Value

gen selfeconknow=.
label var selfeconknow "Self-Desc. Econ Know"
replace selfeconknow=1 if I2_en==2
replace selfeconknow=2 if I2_en==3
replace selfeconknow=3 if I2_en==4
replace selfeconknow=4 if I2_en==1
label define selfeconknow 1 "Not knowledgeable at all" 2 "Not very knowledgeable" ///
3 "Somewhat knowledgeable" 4 "Highly knowledgeable"
label val selfeconknow selfeconknow
tab I2 selfeconknow // check //

drop I2_en

gen selfeconknow_high=.
label var selfeconknow_high "High Self-Desc. Econ Know."
replace selfeconknow_high=0 if selfeconknow>=1 & selfeconknow<=2
replace selfeconknow_high=1 if selfeconknow>=3 & selfeconknow<=4
label define selfeconknow_high 0 "Not very/at all knowledgeable" ///
1 "Somewhat/Highly knowledgeable"
label val selfeconknow_high selfeconknow_high
tab selfeconknow_high I2


****************************************************
***** BACKGROUND: Graduated Tax Rate Knowledge *****
****************************************************

***** Prior Graduated Tax Rate Knowledge *****
tab B1

gen taxscen=.
label var taxscen "Answer to 12-22% bracket prior knowl. question"
replace taxscen=1 if B1=="Scenario 1"
replace taxscen=2 if B1=="Scenario 2"
label define taxscen 1 "Scenario 1" 2 "Scenario 2"
label val taxscen taxscen
tab B1 taxscen // check //

gen taxratemisp=.
label var taxratemisp "Rate Misp."
replace taxratemisp=0 if B1=="Scenario 2"
replace taxratemisp=1 if B1=="Scenario 1"
label define taxratemisp 0 "No Rate Misp." 1 "Rate Misp."
label val taxratemisp taxratemisp
tab B1 taxratemisp // check //


***** Confidence - Prior Graduated Tax Rate Knowledge Answer *****
tab B2

gen taxscen_conf=.
label var taxscen_conf "Confidence: Answer to 12-22% bracket prior knowl. question"
replace taxscen_conf=1 if B2=="Not at all confident"
replace taxscen_conf=2 if B2=="Not too confident"
replace taxscen_conf=3 if B2=="Somewhat confident"
replace taxscen_conf=4 if B2=="Very confident"
label define taxscen_conf 1 "Not at all confident" 2 "Not too confident" ///
3 "Somewhat confident" 4 "Very confident"
label val taxscen_conf taxscen_conf
tab B2 taxscen_conf //check//

***************************************
***** TREATMENT/PLACEBO I: VIDEOS *****
***************************************

tab TP0_1 // placebo video prompt
tab TP0_2 // treatment video prompt
sum Timing_TP0_PageSubmit Timing_TP1_PageSubmit Timing_TP2_1_PageSubmit
tab TP2_2

gen vidtreat=.
label var vidtreat "Tax Rate Vid"
replace vidtreat=0 if TP0_1!=""
replace vidtreat=1 if TP0_2!=""
label define vidtreat 0 "Placebo Vid" 1 "Tax Rate Vid"
label val vidtreat vidtreat

tab TP0_1 vidtreat // check //
tab TP0_2 vidtreat // check //


**********************************
***** LOWER PRE, HIGHER POST *****
**********************************

***** Lower Pre, Higher Post *****
tab P1

gen lowprehighpost=.
label var lowprehighpost "Bracket Misp."
replace lowprehighpost=1 if P1=="Strongly disagree"
replace lowprehighpost=2 if P1=="Somewhat disagree"
replace lowprehighpost=3 if P1=="Neither agree nor disagree"
replace lowprehighpost=4 if P1=="Somewhat agree"
replace lowprehighpost=5 if P1=="Strongly agree"
label define lowprehighpost 1 "Strongly disagree" 2 "Somewhat disagree" ///
3 "Neither agree nor disagree" 4 "Somewhat agree" 5 "Strongly agree"
label val lowprehighpost lowprehighpost
tab P1 lowprehighpost // check //

gen lowprehighpost_agree=.
label var lowprehighpost_agree "Agree: BracketJump, DecreaseIncome"
replace lowprehighpost_agree=0 if lowprehighpost>=1 & lowprehighpost<=3
replace lowprehighpost_agree=1 if lowprehighpost>=4 & lowprehighpost<=5
label define lowprehighpost_agree 0 "Not Agree" 1 "Agree"
label val lowprehighpost_agree lowprehighpost_agree
tab lowprehighpost lowprehighpost_agree //check//

gen lowprehighpost_disagree=.
label var lowprehighpost_disagree "Disagree: BracketJump, DecreaseIncome"
replace lowprehighpost_disagree=0 if lowprehighpost>=3 & lowprehighpost<=5
replace lowprehighpost_disagree=1 if lowprehighpost>=1 & lowprehighpost<=2
label define lowprehighpost_disagree 0 "Not Disagree" 1 "Disagree"
label val lowprehighpost_disagree lowprehighpost_disagree
tab lowprehighpost lowprehighpost_disagree //check//


***** Confidence - Lower Pre, Higher Post *****
tab P2

gen lowprehighpost_conf=.
label var lowprehighpost_conf "Confidence in response: BracketJump-DecreaseIncome"
replace lowprehighpost_conf=1 if P2=="Not at all confident"
replace lowprehighpost_conf=2 if P2=="Not too confident"
replace lowprehighpost_conf=3 if P2=="Somewhat confident"
replace lowprehighpost_conf=4 if P2=="Very confident"
label define lowprehighpost_conf 1 "Not at all confident" 2 "Not too confident" ///
3 "Somewhat confident" 4 "Very confident"
label val lowprehighpost_conf lowprehighpost_conf
tab P2 lowprehighpost_conf // check //



******************************************************
***** ALTERNATIVE MEASURES OF TAX RATE KNOWLEDGE *****
******************************************************

/* 
Note: this variable is an indicator =1 if a respondent answered the 12-22 
bracket question correctly, and then also indicated "STRONGLY DISAGREE"  
about the statement referring to jumping brackets decreasing one's income 
*/
gen tbknow=.
label var tbknow"TaxBracketKnowledge"
replace tbknow=1 if taxscen==2 & lowprehighpost==1
replace tbknow=0 if taxscen==1 | lowprehighpost>=2 & (taxscen!=. & lowprehighpost_disagree!=.)
label define tbknow 0 "Limited/No Tax Bracket Knowledge" 1 "Tax Bracket Knowledge"
label val tbknow tbknow



* Limited/Know Tax Rate Knowledge
gen tbknowlimitednone=.
label var tbknowlimitednone "Rate or Bracket Misp."
replace tbknowlimitednone=1 if tbknow==0
replace tbknowlimitednone=0 if tbknow==1
label define tbknowlimitednone 0 "No Rate nor Bracket Misp." 1 "Rate or Bracket Misp."
label val tbknowlimitednone tbknowlimitednone

****************************************************
***** PERCEPTIONS AND PREFERENCES - Tax Policy *****
****************************************************

***** Personal Responses - Edge of 12 percent bracket *****

***** Evade Taxes *****
tab P38_1

gen you_ev=.
label var you_ev "Top 12% Bracket: Evade"
replace you_ev=1 if P38_1=="Not at all"
replace you_ev=2 if P38_1=="A little"
replace you_ev=3 if P38_1=="A moderate amount"
replace you_ev=4 if P38_1=="A lot"
replace you_ev=5 if P38_1=="A great deal"
label define you_ev 1 "Not at all" 2 "A little" 3 "A moderate amount" ///
4 "A lot" 5 "A great deal"
label val you_ev you_ev
tab P38_1 you_ev // check //

*Evade Mod+
gen you_ev_mod=.
label var you_ev_mod "Evade"
replace you_ev_mod=0 if you_ev>=1 & you_ev<=2
replace you_ev_mod=1 if you_ev>=3 & you_ev<=5
tab P38_1 you_ev_mod // check //

*Evade AtAll
gen you_ev_atall=.
label var you_ev_atall "Evade"
replace you_ev_atall=0 if you_ev==1
replace you_ev_atall=1 if you_ev>=2 & you_ev<=5
tab P38_1 you_ev_atall // check //

***** Work Less *****
tab P38_2

gen you_wl=.
label var you_wl "Top 12% Bracket: Work Less"
replace you_wl=1 if P38_2=="Not at all"
replace you_wl=2 if P38_2=="A little"
replace you_wl=3 if P38_2=="A moderate amount"
replace you_wl=4 if P38_2=="A lot"
replace you_wl=5 if P38_2=="A great deal"
label define you_wl 1 "Not at all" 2 "A little" 3 "A moderate amount" ///
4 "A lot" 5 "A great deal"
label val you_wl you_wl
tab P38_2 you_wl // check //

*Work Less Mod+
gen you_wl_mod=.
label var you_wl_mod "Work Less"
replace you_wl_mod=0 if you_wl>=1 & you_wl<=2
replace you_wl_mod=1 if you_wl>=3 & you_wl<=5
tab P38_2 you_wl_mod // check //

*Work Less AtAll
gen you_wl_atall=.
label var you_wl_atall "Work Less"
replace you_wl_atall=0 if you_wl==1
replace you_wl_atall=1 if you_wl>=2 & you_wl<=5
tab P38_2 you_wl_atall // check //


***** Stop working altogether *****
tab P38_3

gen you_sw=.
label var you_sw "Top 12% Bracket: Stop Working Altoghether"
replace you_sw=1 if P38_3=="Not at all"
replace you_sw=2 if P38_3=="A little"
replace you_sw=3 if P38_3=="A moderate amount"
replace you_sw=4 if P38_3=="A lot"
replace you_sw=5 if P38_3=="A great deal"
label define you_sw 1 "Not at all" 2 "A little" 3 "A moderate amount" ///
4 "A lot" 5 "A great deal"
label val you_sw you_sw
tab P38_3 you_sw // check //

*Stop working altogether Mod+
gen you_sw_mod=.
label var you_sw_mod "Stop Working"
replace you_sw_mod=0 if you_sw>=1 & you_sw<=2
replace you_sw_mod=1 if you_sw>=3 & you_sw<=5
tab P38_3 you_sw_mod // check //

*Stop working altogether AtAll
gen you_sw_atall=.
label var you_sw_atall "Stop Working"
replace you_sw_atall=0 if you_sw==1
replace you_sw_atall=1 if you_sw>=2 & you_sw<=5
tab P38_3 you_sw_atall // check //


***** Spouse stops working *****
tab P38_4

gen you_sp=.
label var you_sp "Top 12% Bracket: Spouse Stops Working"
replace you_sp=1 if P38_4=="Not at all"
replace you_sp=2 if P38_4=="A little"
replace you_sp=3 if P38_4=="A moderate amount"
replace you_sp=4 if P38_4=="A lot"
replace you_sp=5 if P38_4=="A great deal"
label define you_sp 1 "Not at all" 2 "A little" 3 "A moderate amount" ///
4 "A lot" 5 "A great deal"
label val you_sp you_sp
tab P38_4 you_sp // check //

*Spouse Stops Working Mod+
gen you_sp_mod=.
label var you_sp_mod "Spouse Stops Working"
replace you_sp_mod=0 if you_sp>=1 & you_sp<=2
replace you_sp_mod=1 if you_sp>=3 & you_sp<=5
tab P38_4 you_sp_mod // check //

*Spouse Stops Working AtAll
gen you_sp_atall=.
label var you_sp_atall "Spouse Stops Working"
replace you_sp_atall=0 if you_sp==1
replace you_sp_atall=1 if you_sp>=2 & you_sp<=5
tab P38_4 you_sp_atall // check //


**** Less entr./fewer businesses ****
tab P38_5

gen you_le=.
label var you_le "Top 12% Bracket: Less Entr./Fewer Bus."
replace you_le=1 if P38_5=="Not at all"
replace you_le=2 if P38_5=="A little"
replace you_le=3 if P38_5=="A moderate amount"
replace you_le=4 if P38_5=="A lot"
replace you_le=5 if P38_5=="A great deal"
label define you_le 1 "Not at all" 2 "A little" 3 "A moderate amount" ///
4 "A lot" 5 "A great deal"
label val you_le you_le
tab P38_5 you_le // check //

*Less entr./fewer businesses Mod+
gen you_le_mod=.
label var you_le_mod "Less Entr. / Fewer Bus."
replace you_le_mod=0 if you_le>=1 & you_le<=2
replace you_le_mod=1 if you_le>=3 & you_le<=5
tab P38_5 you_le_mod // check //

*Less entr./fewer businesses
gen you_le_atall=.
label var you_le_atall "Less Entr. / Fewer Bus."
replace you_le_atall=0 if you_le==1
replace you_le_atall=1 if you_le>=2 & you_le<=5
tab P38_5 you_le_atall // check //


***** Turn down small raise/avoid income increase *****
tab P38_6

gen you_av=.
label var you_av "Top 12% Bracket: Turn down raise/avoid income increase"
replace you_av=1 if P38_6=="Not at all"
replace you_av=2 if P38_6=="A little"
replace you_av=3 if P38_6=="A moderate amount"
replace you_av=4 if P38_6=="A lot"
replace you_av=5 if P38_6=="A great deal"
label define you_av 1 "Not at all" 2 "A little" 3 "A moderate amount" ///
4 "A lot" 5 "A great deal"
label val you_av you_av
tab P38_6 you_av // check //

*Turn down small raise/avoid income increase Mod+
gen you_av_mod=.
label var you_av_mod "Avoid Raise / Income Incr."
replace you_av_mod=0 if you_av>=1 & you_av<=2
replace you_av_mod=1 if you_av>=3 & you_av<=5
tab P38_6 you_av_mod // check //

*Turn down small raise/avoid income increase Mod+
gen you_av_atall=.
label var you_av_atall "Avoid Raise / Income Incr."
replace you_av_atall=0 if you_av==1
replace you_av_atall=1 if you_av>=2 & you_av<=5
tab P38_6 you_av_atall // check //


*****************************************
***** OTHER BELIEFS AND PREFERENCES *****
*****************************************

***** Gov Trust *****
tab O1

gen govtrust=.
label var govtrust "How often can you trust US govt"
replace govtrust=1 if O1=="Never"
replace govtrust=2 if O1=="Only some of the time"
replace govtrust=3 if O1=="Most of the time"
replace govtrust=4 if O1=="Always"
label define govtrust 1 "Never" 2 "Only some of the time" ///
3 "Most of the time" 4 "Always"
label val govtrust govtrust
tab O1 govtrust //check//

gen govtrust_mostly=.
label var govtrust_mostly "Trust Gov: Mostly/Always"
replace govtrust_mostly=0 if govtrust==1 | govtrust==2
replace govtrust_mostly=1 if govtrust==3 | govtrust==4
label define govtrust_mostly 0 "Never/only sometimes" 1 "Mostly/Always"
label val govtrust_mostly govtrust_mostly
tab govtrust govtrust_mostly //check//


***** Inequality Beliefs *****

* Inequality Serious Problem
tab O23_1

gen ineqprob=.
label var ineqprob "Income Ineq.: SeriousProblem"
replace ineqprob=1 if O23_1=="Strongly disagree"
replace ineqprob=2 if O23_1=="Somewhat disagree"
replace ineqprob=3 if O23_1=="Neither agree nor disagree"
replace ineqprob=4 if O23_1=="Somewhat agree"
replace ineqprob=5 if O23_1=="Strongly agree"
label define ineqprob 1 "Strongly disagree" 2 "Somewhat disagree" ///
3 "Neither agree nor disagree" 4 "Somewhat agree" 5 "Strongly agree"
label val ineqprob ineqprob
tab O23_1 ineqprob //check//


* Govt should reduce inequality
tab O23_2

gen govredineq=.
label var govredineq "Income Ineq.: GovtShouldReduce"
replace govredineq=1 if O23_2=="Strongly disagree"
replace govredineq=2 if O23_2=="Somewhat disagree"
replace govredineq=3 if O23_2=="Neither agree nor disagree"
replace govredineq=4 if O23_2=="Somewhat agree"
replace govredineq=5 if O23_2=="Strongly agree"
label define govredineq 1 "Strongly disagree" 2 "Somewhat disagree" ///
3 "Neither agree nor disagree" 4 "Somewhat agree" 5 "Strongly agree"
label val govredineq govredineq
tab O23_2 govredineq //check//

***** Beliefs about why one is rich *****
tab O4

encode O4, gen(O4_en)
tab O4_en
label list O4_en // Shows Label and Value

gen hardwork=.
label var hardwork "Rich because: HardWork"
replace hardwork=0 if O4_en==1
replace hardwork=1 if O4_en==2
label define hardwork 0 "Rich because: MoreAdvantages" 1 "Rich because: HardWork"
tab O4 hardwork //check//

drop O4_en

***** Effectiveness of govt spending *****
tab O5

gen govspending=.
label var govspending "GovSpendingEffectiveness"
replace govspending=1 if O5=="Very ineffectively"
replace govspending=2 if O5=="Somewhat ineffectively"
replace govspending=3 if O5=="Neither effectively nor ineffectively"
replace govspending=4 if O5=="Somewhat effectively"
replace govspending=5 if O5=="Very effectively"
label define govspending 1 "Very ineffectively" 2 "Somewhat ineffectively" ///
3 "Neither effectively nor ineffectively" 4 "Somewhat effectively" ///
5 "Very effectively"
label val govspending govspending
tab O5 govspending //check//


***** News Consumption *****
tab O6_1
gen news_national=.
replace news_national=1 if O6_1!=""
replace news_national=0 if O6_1==""

tab O6_2
gen news_cable=.
replace news_cable=1 if O6_2!=""
replace news_cable=0 if O6_2==""

tab O6_3
gen newspaper=.
replace newspaper=1 if O6_3!=""
replace newspaper=0 if O6_3==""

tab O6_4
gen internetsocmed=.
replace internetsocmed=1 if O6_4!=""
replace internetsocmed=0 if O6_4==""

tab O6_5 
gen radio=.
replace radio=1 if O6_5!=""
replace radio=0 if O6_5==""

tab O6_6
gen magazine=.
replace magazine=1 if O6_6!=.
replace magazine=0 if O6_6==.

tab O6_7 
gen news_wordofmouth=.
replace news_wordofmouth=1 if O6_7!=""
replace news_wordofmouth=0 if O6_7==""

tab O6_8 
gen news_other=.
replace news_other=1 if O6_8!=""
replace news_other=0 if O6_8==""

tab O6_9 
gen news_dontfollow=.
replace news_dontfollow=1 if O6_9!=""
replace news_dontfollow=0 if O6_9==""


***** Weed legalization *****
tab O7

gen legalizeweed=.
label var legalizeweed "Support legalization of marijuana"
replace legalizeweed=1 if O7=="No"
replace legalizeweed=2 if O7=="Maybe"
replace legalizeweed=3 if O7=="Yes"
label define legalizeweed 1 "No" 2 "Maybe" 3 "Yes"
label val legalizeweed
tab O7 legalizeweed //check//


************************
***** DEMOGRAPHICS *****
************************

***** Taxpaying and Transfer Experience Variables *****

* Personally Filed
tab D16_1

gen persfiled=.
label var persfiled "PersonallyFiledTaxes"
replace persfiled=0 if D16_1=="" & complete==1
replace persfiled=1 if D16_1!=""
label define persfiled 0 "No" 1 "Yes"
label val persfiled persfiled
tab D16_1 persfiled //check//
tab persfiled


* Tax Assistance
tab D16_2

gen taxassist=.
label var taxassist "TaxPrepAssistance"
replace taxassist=0 if D16_2=="" & complete==1
replace taxassist=1 if D16_2!=""
label define taxassist 0 "No" 1 "Yes"
label val taxassist taxassist
tab D16_2 taxassist //check//
tab taxassist


* Itemized Deductions
tab D16_3

gen itemizer=.
label var itemizer "ItemizesDeductions"
replace itemizer=0 if D16_3=="" & complete==1
replace itemizer=1 if D16_3!=""
label define itemizer 0 "No" 1 "Yes"
label val itemizer itemizer
tab D16_3 itemizer //check//
tab itemizer


* Government Benefits
tab D16_4 

gen govbenefits=.
label var govbenefits "GovBenefits"
replace govbenefits=0 if D16_4=="" & complete==1
replace govbenefits=1 if D16_4!=""
label define govbenefits 0 "No" 1 "Yes"
label val govbenefits govbenefits
tab D16_4 govbenefits //check//
tab govbenefits


* Claimed EITC
tab D16_5

gen eitc=.
label var eitc "Claimed EITC"
replace eitc=0 if D16_5=="" & complete==1
replace eitc=1 if D16_5!=""
label define eitc 0 "No" 1 "Yes"
label val eitc eitc
tab D16_5 eitc //check//
tab eitc


* Claimed CTC
tab D16_6

gen ctc=.
label var ctc "Claimed CTC"
replace ctc=0 if D16_6=="" & complete==1
replace ctc=1 if D16_6!=""
label define ctc 0 "No" 1 "Yes"
label val ctc ctc
tab D16_6 ctc //check//
tab ctc


***** Economic Ideology *****
tab D7

gen econideol=.
label var econideol "Econ. Ideology"
replace econideol=1 if D7=="Very liberal"
replace econideol=2 if D7=="Liberal"
replace econideol=3 if D7=="Moderate"
replace econideol=4 if D7=="Conservative"
replace econideol=5 if D7=="Very conservative"
label define econideol 1 "Very liberal" 2 "Liberal" 3 "Moderate" ///
4 "Conservative" 5 "Very conservative"
label val econideol econideol
tab D7 econideol //check//

gen econideol_agg=.
label var econideol_agg "Econ. Ideology"
replace econideol_agg=1 if econideol>=1 & econideol<=2
replace econideol_agg=2 if econideol==3
replace econideol_agg=3 if econideol>=4 & econideol<=5
label define econideol_agg 1 "Liberal" 2 "Moderate" 3 "Conservative"
label val econideol_agg econideol_agg
tab econideol econideol_agg //check//

gen liberal=.
label var liberal "Liberal"
replace liberal=0 if econideol_agg==2 | econideol_agg==3
replace liberal =1 if econideol_agg==1
tab liberal econideol //check//

gen moderate=.
label var moderate "Moderate"
replace moderate=0 if econideol_agg==1 | econideol_agg==3
replace moderate=1 if econideol_agg==2
tab moderate econideol //check//

gen conservative=.
label var conservative "Conservative"
replace conservative=0 if econideol_agg==1 | econideol_agg==2
replace conservative=1 if econideol_agg==3
tab conservative econideol //check//


***** Party Aff *****
tab D8

gen partyaff=.
label var partyaff "Party Affiliation"
replace partyaff=1 if D8=="Democrat"
replace partyaff=2 if D8=="Independent"
replace partyaff=3 if D8=="Republican"
replace partyaff=4 if D8=="Non-Affiliated"
replace partyaff=5 if D8=="Other"
label define partyaff 1 "Democrat" 2 "Independent" 3 "Republican" ///
4 "Non-Affiliated" 5 "Other"
label val partyaff partyaff

gen partyaff_agg=.
label var partyaff_agg "Party Affiliation"
replace partyaff_agg=1 if partyaff==1
replace partyaff_agg=2 if partyaff==2 | partyaff==4 | partyaff==5
replace partyaff_agg=3 if partyaff==3
label define partyaff_agg 1 "Democrat" 2 "Independent/Other" 3 "Republican" 
label val partyaff_agg partyaff_agg

gen democrat=.
label var democrat "Democrat"
replace democrat=1 if partyaff_agg==1
replace democrat=0 if partyaff_agg==2 | partyaff_agg==3
label define democrat 0 "Not Democrat" 1 "Democrat"
label val democrat democrat

gen independent=.
label var independent "Independent/Other"
replace independent=1 if partyaff_agg==2
replace independent=0 if partyaff_agg==1 | partyaff_agg==3
label define independent 0 "Not Independent/Other" 1 "Independent/Other"
label val independent independent

gen republican=.
label var republican "Republican"
replace republican=1 if partyaff_agg==3
replace republican=0 if partyaff_agg==1 | partyaff_agg==2
label define republican 0 "Republican" 1 "Republican"
label val republican republican


***** Gender *****
tab D9

encode D9, gen(D9_en)
tab D9_en
label list D9_en // Shows Label and Value

gen gender=.
label var gender "Gender"
replace gender=0 if D9_en==1
replace gender=1 if D9_en==2
replace gender=2 if D9_en==3 | D9_en==4
label define gender 0 "Female" 1 "Male" 2 "Other/Prefer not to say"
label val gender gender
tab D9 gender //check//

gen male=.
label var male "Male"
replace male=1 if gender==1
replace male=0 if gender==0 | gender==2
label define male 0 "Not Male" 1 "Male"
label val male male
tab D9 male //check//

drop D9_en


***** Age *****
tab D10_1

gen age=D10_1
label var age "Age"

gen agegroup=.
label var agegroup "Age Group"
replace agegroup=1 if age>=18 & age<=29
replace agegroup=2 if age>=30 & age<=39
replace agegroup=3 if age>=40 & age<=49
replace agegroup=4 if age>=50 & age<=59
replace agegroup=5 if age>=60 & age<=69
replace agegroup=6 if age>=70
label define agegroup 1 "18-29" 2 "30-49" 3 "40-49" 4 "50-59" 5 "60-69" 6 "70+"
label val agegroup agegroup
tab D10_1 agegroup //check//

gen agegroup_agg=.
label var agegroup_agg "Age Group"
replace agegroup_agg=1 if age>=18 & age<=29
replace agegroup_agg=2 if age>=30 & age<=49
replace agegroup_agg=3 if age>=50 & age!=.
label define agegroup_agg 1 "18-29 years" 2 "30-49 years" 3 "50+ years"
label val agegroup_agg agegroup_agg
tab agegroup agegroup_agg //check//


***** Educ *****
tab D11

gen educ=.
label var educ "Highest Level of Education"
replace educ=1 if D11=="Primary education or less"
replace educ=2 if D11=="Some High School"
replace educ=3 if D11=="High School degree/GED"
replace educ=4 if D11=="Some College"
replace educ=5 if D11=="2-year College Degree"
replace educ=6 if D11=="4-year College Degree"
replace educ=7 if D11=="Master's Degree"
replace educ=8 if D11=="Doctoral Degree"
replace educ=9 if D11=="Professional Degree (JD, MD, MBA)"
label define educ 1 "Primary education or less" 2 "Some High School" ///
3 "High School degree/GED" 4 "Some College" 5 "2-year College Degree" ///
6 "4-year College Degree" 7 "Master's Degree" 8 "Doctoral Degree" ///
9 "Professional Degree (JD, MD, MBA)"
label val educ educ
tab D11 educ //check//

gen educ_agg=.
label var educ_agg "Highest Level of Education"
replace educ_agg=1 if educ>=1 & educ<=3
replace educ_agg=2 if educ>=4 & educ<=5
replace educ_agg=3 if educ>=6 & educ<=9
label define educ_agg 1 "High school or less" 2 "Some college/2-year degree" ///
3 "4-Year college or higher"
label val educ_agg educ_agg
tab D11 educ_agg //check//

gen collegedeg=.
label var collegedeg "College Degree +"
replace collegedeg=0 if educ>=1 & educ<=6
replace collegedeg=1 if educ>=6 & educ<=9
label define collegedeg 0 "No college degree" 1 "4-Year college or higher"
label val collegedeg collegedeg
tab D11 collegedeg //check//


***** Children *****
tab D12

gen children=.
label var children "Num. Children"
replace children=0 if D12=="I do not have children"
replace children=1 if D12=="1"
replace children=2 if D12=="2"
replace children=3 if D12=="3"
replace children=4 if D12=="4"
replace children=5 if D12=="5 or more"
label define children 0 "No children" 1 "1" 2 "2" 3 "3" 4 "4" 5 "5+"
label val children children
tab D12 children //check//

gen kids=.
label var kids "Has Children"
replace kids=0 if children==0
replace kids=1 if children>=1 & children<=5
label define kids 0 "No children" 1 "Has children"
label val kids kids
tab D12 kids //check//


***** Married: Currently or Ever *****
tab D13

gen married=.
label var married "Current / Ever Married"
replace married=0 if D13=="No"
replace married=1 if D13=="Yes"
label define married 0 "Never Married" 1 "Married"
label val married married
tab D13 married //check//


***** Race/Ethnicity *****
tab D14

gen race=.
label var race "Race/Ethnicity"
replace race=1 if D14=="European American/White"
replace race=2 if D14=="African American/Black"
replace race=3 if D14=="Hispanic/Latino"
replace race=4 if D14=="Asian/Asian American"
replace race=5 if D14=="Native American/American Indian"
replace race=6 if D14=="Other"
label define race 1 "White" 2 "Black" 3 "Hispanic/Latino" 4 "Asian" ///
5 "Native American/American Indian" 6 "Other"
label val race race
tab D14 race //check//

gen race_agg=.
label var race_agg "Race/Ethnicity"
replace race_agg=1 if race==1
replace race_agg=2 if race==2
replace race_agg=3 if race==3
replace race_agg=4 if race==4
replace race_agg=5 if race>=5 & race<=6
label define race_agg 1 "White" 2 "Black" 3 "Hispanic/Latino" ///
4 "Asian/Asian Amer." 5 "Other"
label val race_agg race_agg
tab D14 race_agg //check//


***** State *****
tab D15

encode D15, gen(D15_en)
tab D15_en
label list D15_en // Shows Label and Value

// edit later //

gen region=.
label var region "Region"

replace region=1 if D15=="Connecticut" | D15=="Maine" | D15=="Massachusetts" ///
| D15=="New Hampshire" | D15=="New Jersey" | D15=="New York" ///
| D15=="Pennsylvania" | D15=="Rhode Island" | D15=="Vermont"

replace region=2 if D15=="Illinois" | D15=="Indiana" | D15=="Iowa" ///
| D15=="Kansas" | D15=="Michigan" | D15=="Minnesota" ///
| D15=="Missouri" | D15=="Nebraska" | D15=="North Dakota" ///
| D15=="Ohio" | D15=="South Dakota" | D15=="Wisconsin"

replace region=3 if D15=="Alabama" | D15=="Arkansas" | D15=="Delaware" ///
| D15=="District of Columbia" | D15=="Florida" | D15=="Georgia" ///
| D15=="Kentucky" | D15=="Louisiana" | D15=="Maryland" ///
| D15=="Mississippi" | D15=="North Carolina" | D15=="Oklahoma" ///
| D15=="South Carolina" | D15=="Tennessee" | D15=="Texas" ///
| D15=="Virginia" | D15=="West Virginia"

replace region=4 if D15=="Alaska" | D15=="Arizona" | D15=="California" ///
| D15=="Colorado" | D15=="Hawaii" | D15=="Idaho" ///
| D15=="Montana" | D15=="Nevada" | D15=="New Mexico" ///
| D15=="Oregon" | D15=="Utah" | D15=="Washington" ///
| D15=="Wyoming"

label define region 1 "Northeast" 2 "Midwest" 3 "South" 4 "West"
label val region region


***** Employment Status *****
tab D16

gen empstatus=.
label var empstatus "Employment Status"
replace empstatus=1 if D16=="Full-time employee"
replace empstatus=2 if D16=="Part-time employee"
replace empstatus=3 if D16=="Self-employed"
replace empstatus=4 if D16=="Small business owner"
replace empstatus=5 if D16=="Medium or large business owner"
replace empstatus=6 if D16=="Unemployed and looking for work"
replace empstatus=7 if D16=="Student"
replace empstatus=8 if D16=="Not currently working and not looking for work (e.g. full-time parent)"
replace empstatus=9 if D16=="Retiree"
label define empstatus 1 "Full-time employee" 2 "Part-time employee" ///
3 "Self-employed" 4 "Small business owner" 5 "Medium or large business owner" ///
6 "Unemployed and looking for work" 7 "Student" ///
8 "Not currently working and not looking for work (e.g. full-time parent)" ///
9 "Retiree"
label val empstatus empstatus
tab D16 empstatus //check//

gen emp=.
label var emp "Employment Status"
replace emp=1 if D16=="Full-time employee"
replace emp=2 if D16=="Part-time employee"
replace emp=3 if D16=="Self-employed"
replace emp=4 if D16=="Small business owner" | D16=="Medium or large business owner"
replace emp=5 if D16=="Unemployed and looking for work"
replace emp=6 if D16=="Student"
replace emp=7 if D16=="Not currently working and not looking for work (e.g. full-time parent)"
replace emp=8 if D16=="Retiree"
label define emp 1 "Full-time employee" 2 "Part-time employee" ///
3 "Self-employed" 4 "Business owner" 5 "Unemployed and looking for work" ///
6 "Student" 7 "Not working, not looking" ///
8 "Retiree"
label val emp emp
tab D16 emp // check //


***** Household Income *****
tab D17

gen income=.
label var income "Household Income (2022)"
replace income=1 if D17=="$0 - $9,999"
replace income=2 if D17=="$10,000 - $14,999"
replace income=3 if D17=="$15,000 - $19,999"
replace income=4 if D17=="$20,000 - $29,999"
replace income=5 if D17=="$30,000 - $39,999"
replace income=6 if D17=="$40,000 - $49,999"
replace income=7 if D17=="$50,000 - $69,999"
replace income=8 if D17=="$70,000 - $89,999"
replace income=9 if D17=="$90,000 - $109,999"
replace income=10 if D17=="$110,000 - $149,999"
replace income=11 if D17=="$150,000 - $199,999"
replace income=12 if D17=="$200,000 +"
label define income 1 "$0 - $9,999" 2 "$10,000 - $14,999" 3 "$15,000 - $19,999" ///
4 "$20,000 - $29,999" 5 "$30,000 - $39,999" 6 "$40,000 - $49,999" ///
7 "$50,000 - $69,999" 8 "$70,000 - $89,999" 9 "$90,000 - $109,999" ///
10 "$110,000 - $149,999" 11 "$150,000 - $199,999" 12 "$200,000 +"
label val income income
tab D17 income //check//

gen income_agg=.
label var income_agg "Household Income (2022)"
replace income_agg=1 if income>=1 & income<=3
replace income_agg=2 if income>=4 & income<=5
replace income_agg=3 if income>=6 & income<=7
replace income_agg=4 if income>=8 & income<=9
replace income_agg=5 if income>=10 & income<=12
label define income_agg 1 "$0 - $19,999" 2 "$20,000 - $39,999" ///
3 "$40,000 - $69,999" 4 "$70,000 - $109,999" 5 "$110,000+"
label val income_agg income_agg
tab D17 income_agg

gen income_high=.
label var income_high "High Income $110k +"
replace income_high=1 if income_agg==5
replace income_high=0 if income_agg<5 & income_agg!=.
label define income_high 1 "$110k +" 0 "< $110k"
label val income_high income_high
tab D17 income_high

***** Final Comments *****
gen comments=D19


********************************
***** IDENTIFYING SPEEDERS *****
********************************

***** Treat and Placebo Videos *****
gen dur_treatvid=.
replace dur_treatvid=Durationinminutes if vidtreat==1
sum dur_treatvid, detail

gen flag_treatvid=(dur_treatvid<r(p5))
label var flag_treatvid "GradTaxRateVid Speeder"

//
gen dur_placebovid=.
replace dur_placebovid=Durationinminutes if vidtreat==0
sum dur_placebovid, detail

gen flag_placebovid=(dur_placebovid<r(p5))
label var flag_placebovid "PlaceboVid Speeder"

gen vidspeeder=.
replace vidspeeder=1 if flag_placebovid==1 | flag_treatvid==1


********************************
******* ATTENTION CHECKS *******
********************************

gen att1_pass=.
replace att1_pass=1 if ATTCH_1_1=="Strongly disagree" & ATTCH_1_5=="Strongly agree" ///
& ATTCH_1_2==. & ATTCH_1_3==. & ATTCH_1_4==""
tab att1_pass

gen att2_pass=.
replace att2_pass=1 if ATTCH_2=="Apple"
replace att2_pass=0 if ATTCH_2!="Apple" & ATTCH_2!=""
tab att2_pass

gen att_passed=.
replace att_passed=1 if att1_pass==1 & att2_pass==1
tab att_passed


*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*
*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*
*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*

**************** For Tables and Figures, Proceed to File 2 *********************

